/**
 * made by Maowl
 */

(function($){
    $.fn.autoZindexTop = function(options_events){
		var opts = $.extend({}, 
							{	
								/*options*/
								cleanHandler: null
							},
							options_events);
				
		var objs = $(this);
		
		objs.mousedown(function(event){
			event.stopPropagation();
			
			$.each(objs, function(k, v){
				$(v).css('z-index', $(v).data('z-index'));
			});
			$(this).css('z-index', 10000);
		});
		
		opts.cleanHandler.mousedown(function(){
			$.each(objs, function(k, v){
				$(v).css('z-index', $(v).data('z-index'));
			});
		});
							
		return $(this).each(function(){
			$(this).data('z-index', $(this).css('z-index'));
		});
	};
})(window.jQuery);